//验证是否未email
function IsEmail(str)
{
var reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; 
return reg.test(str);
}

function fleshVerify(){
//重载验证码
var timenow = new Date().getTime();
$('verifyImg').src= APP+'/Public/verify/'+timenow;
}


//弹出提示消息
function msg(title,msgs){
			$j.messager.show({
				title:title,
				msg:msgs,
				timeout:5000,
				showType:'slide'
			});		
	}
//ajax 方式访问某个方法，参数是个字符串，post方式访问，回调函数callback()	
function ajaxGet(urlstr,datastr,callback)	
	{	
		var myRequest = new Request.JSON({
			url: urlstr,
			data: datastr,
			onComplete: function(rt){
				//alert(rt);	
				//alert('before'+rt[0]['status']);
			if(rt[0]['status']!='error')
			{
				callback(rt);
			}
			else
				{
					msg('报错',rt[0]['status']+':'+rt[0]['msg']);
				}
			}	
		}).send();
	}


//获得团队id
function getTeamId(){
 var tm = $defined(Cookie.read('teamId__'))?Cookie.read('teamId__'):false;
 return tm;
	}		
	
	

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}	


//更新easyui tab函数，ajax访问url,divid是tab的container
  function updateTab(divid,urlstr){
  
	var pp = $j('#'+divid).tabs('getSelected');	
  	$j('#tabarry').tabs('update', {
				tab: pp,		
				options:{
					href: urlstr
				}
			});	
  }
  //查看任务细节，需要模板配合
  function seeTask(kind,id_gezi_task,urlstr)
  {
   //先显示窗口，domready后ajax 调用，href是load，参数是id-task，返回结果插入到格子空位
   //窗体预先make优惠券格子位置
var status = 'Full';
 	switch(kind)
   {
   case 'dtask':
		 {
		status='Full';
		 }
	 break
   case 'ftask' :
		{
		 status='Adding'; 
		}
	 break
   case 'myAddingtask' :
		{
		 status='Adding'; 
		}
	 break   
   case 'myFullTask' :
		{
		 status='Full'; 
		}
	 break   	 
	 
   default:
	       status='Full';
   }

 
	var callback = function(data)
     {
		if(data[0]['status']='ok')
		{
			if($chk(data[0]['data'])) 
			{
			var recs = data[0]['data'];
			//alert(kind);
			for(i=1;i<=recs.length;i++)
				{				
				$(kind+i.toString()).innerHTML = "<a href='"+recs[i-1]['productUrl'] + "' target='_blank'> <img src='"+recs[i-1]['pPic']+"' border=0 width=79 height=54 title='"+recs[i-1]['tCode']+"' /> </a>";
				}
			}
			else msg('错误!'+data[0]['msg']);
		}
	  }
	var datastr = 'id_gezi_task='+id_gezi_task+'&status='+status;
	//alert(datastr);
	ajaxGet(urlstr,datastr,callback);    
  }
  
  //初始化指定的任务div，24格
  function initTaskDiv(kind,[paneldiv])
  {
	   	for(i=0;i<24;i++)
	{
	var obj =kind+(i+1).toString();
		$(obj).setStyles({width:'80px',height:'55px','background-color': '#E0ECFF',margin: '2px 1px 2px 2px'});		
	} 
  }